package com.tsunami.authority.component;

import com.tsunami.utils.MD5;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * MD5密码加密
 *
 * @author lx
 * @since 2021-11-19 10:06
 */
public class MD5PasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence charSequence) {
        return MD5.encrypt(charSequence.toString());
    }

    @Override
    public boolean matches(CharSequence charSequence, String encodedPassword) {
        return encodedPassword.equals(MD5.encrypt(charSequence.toString()));
    }

    public static void main(String[] args) {
        System.out.println(MD5.encrypt("123456"));
    }
}
